Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

460
Vistas
JsPDF Uncaught ReferenceError: jsPDF is not defined"

I am trying to save a div as a PDF using jsPDF. Here is my fiddle: https://jsfiddle.net/waleedbinahmed/bfj6qktv/11/ and here is a fiddle that someone else has uploaded: https://jsfiddle.net/waleedbinahmed/8s4qvu27/

The second fiddle is working fine.

I have tried to mimic the second fiddle i.e. including the same js and Jquery libraries. But on my fiddle, I am getting this error "Uncaught ReferenceError: jsPDF is not defined".

I don't know what I am missing on my fiddle that is causing the issue. Please help me out with what needs to be updated with respect to the second fiddle so that I can save a div a PDF.

JS library: https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.debug.js

Here is my code: HTML:

<div id="content">
  <h3>Hello, this is a H3 tag</h3>

  <p>A paragraph</p>
</div>
<div id="editor"></div>
<button onclick="javascript:createPdf()" id="cmd">generate PDF</button>

Javascript:

function createPdf() {
     var doc = new jsPDF();
    
      source = $('#content')[0];
    
      specialElementHandlers = {
        '#editor': function(element, renderer) {
          return true
        }
      };
    
      doc.fromHTML(
        source,
        15,
        15, {
          'width': 170,
          'elementHandlers': specialElementHandlers
        }
      );
      doc.save('sample-file.pdf')
    }

thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

i did watch to your fiddle (the first one that was not working correctly), and just paste js library from the correct fiddle

and its working. sounds like your imported library doesn't work. and also the working fiddle has a jquery 3.4.1 implemented

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda